package org.gradle;

import com.alibaba.fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.websocket.OnMessage;
import javax.websocket.server.ServerEndpoint;

@ServerEndpoint(value = "/echo", encoders = {WebSocketEncoders.class}, decoders = {WebSocketDncoders.class})
public class EncoServer {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @OnMessage
    public Message echo(Message msg){
        logger.info(JSON.toJSONString(msg));
        Message result = new Message();
        result.setContent("Server:" + msg.getContent());
        result.setSubject("服务器端回复");
        return result;
    }
}
